
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            width: 560px;
            height: 312px;
            background-color: rgb(249, 247, 248);
            border: 1px solid rgb(222, 222, 222);
            margin-left: 10px;
            margin-top: 10px;
        }

        .left {
            width: 456px;
            float: left;
        }

        .left img {
            width: 440px;
            height: 293px;
            margin-left: 8px;
            margin-top: 8px;
        }

        .right {
            height: 293px;
            margin-left: 8px;
            margin-top: 8px;
        }

        .right img {
            width: 95px;
            height: 62px;
            margin-top: 8px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="left"><img src="./1.jpg" /></div>
        <div class="right">
            <img src="./1.jpg" />
            <img src="./2.jpg" />
            <img src="./3.jpg" />
            <img src="./4.jpg" />
        </div>
    </div>
</body>

<script>
    let aa =document.querySelector(".left")
    // 1、自动切换 图片
    // 2、鼠标移入右侧的图片 左边切换到对应的图片  鼠标移出  以当前的图片 自动继续切换图片
let imgindex=1
let timer;
function fn(){
    timer=setInterval(function(){

aa.setAttribute("src",`./${imgindex}.jpg`); 
imgindex++
if(imgindex==5){
    imgindex=1
}
        },1000)
}
fn()

let b = document.querySelectorAll(".right>img")
            for(var i = 0;i<b.length;i++){
        //onmouseover 鼠标滑动
        b[i].dataset.index = i
        b[i].onmouseover = handler;
       b[i].onmouseout=handler1;
    }

    function handler(){
        var index = parseInt(this.dataset.index) +1
        console.log(index)
        document.querySelector(".left>img").setAttribute("src",`./${index}.jpg`);
clearInterval(timer)

        }

        function handler1(){
fn()

aa.src = this.src;
        }
       /*  function handler1(){

            setInterval(function(){

var a =document.querySelector(".left>img").setAttribute("src",`./${index}.jpg`); 
index++
if(index==5){
    index=1
}
        },1000)


            index = this.index;
            console.log
        } */
   


               
</script>